var pic = document.querySelector('.header .container .pic')
var logo = document.querySelector('.header .container .pic img')
var box = document.querySelector('.header .container .box ')
var input = document.querySelector('.header .container .box .search input')
var searchBtn = document.querySelector('.header .container .box .sousuo')
var dropdown = document.querySelector('.header .container .box .search .dropdown')
var slide = document.querySelectorAll('.header .headerbox .slide')
var lis = document.querySelectorAll('.header .container .title ul li')
var lis2 = document.querySelectorAll('.site-content .container .slideBox .nav ul li')
var daojishi = document.querySelectorAll('.se-count .se-txt')
var childrenLi = document.querySelectorAll('.body .goods .buy-box')

$(function () {
    $(lis).mouseover(function () {
        $(this).css('color', '#ff6700').siblings().css('color', 'black');
        var index = $(this).index();
        console.log(index);
        if (index < 7) {
            $(slide).eq(index).stop().slideDown(600).siblings().slideUp(100);
        }
    });
    $(lis).mouseout(function () {
        $(slide).stop().slideUp(600);
        $(this).css('color', 'black')
    });
    $(lis2).mouseover(function () {
        $(this).css({ 'backgroundColor': '#ff6700' })
    });
    $(lis2).mouseout(function () {
        $(this).css({ 'backgroundColor': '#9f9a96', 'opacity': '0.8' })
    })
})

logo.onmouseover = function () {
    console.log('123');
    logo.src = './pic/mi-home.png'
    logo.className = 'mouseover'
},
    logo.onmouseout = function () {
        console.log('123');
        logo.src = './pic/mi-logo.png'
        logo.className = 'mouseout'
    },
    input.onfocus = function () {
        box.style.borderColor = "#ff6700"
        searchBtn.style.borderColor = "#ff6700"
        dropdown.style.display = 'block'
    },
    input.onblur = function () {
        box.style.borderColor = "#e0e0e0"
        searchBtn.style.borderColor = "#e0e0e0"
        dropdown.style.display = 'none'
    }


countDown();
setInterval(countDown, 1000);

function countDown() {
    var nowTime = new Date()
    let downHour = 14
    nowHours = nowTime.getHours();//0-23h
    downtime = nowHours > (downHour - 1) ? (new Date(new Date().toLocaleDateString()).getTime() + (24 + downHour) * 60 * 60 * 1000) : (new Date(new Date().toLocaleDateString()).getTime() + downHour * 60 * 60 * 1000)
    var inputTime = new Date(downtime)
    var times = (inputTime - nowTime) / 1000
    var d = parseInt(times / 60 / 60 / 24)
    d = d < 10 ? '0' + d : d
    var h = parseInt(times / 60 / 60 % 24)
    daojishi[0].innerHTML = h < 10 ? '0' + h : h
    var m = parseInt(times / 60 % 60)
    daojishi[1].innerHTML = m < 10 ? '0' + m : m
    var s = parseInt(times % 60)
    daojishi[2].innerHTML = s < 10 ? '0' + s : s
}

